package com.adee.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class JDK {
    public static final char[] digits = {
            '0' , '1' , '2' , '3' , '4' , '5' ,
            '6' , '7' , '8' , '9' , 'a' , 'b' ,
            'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
            'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
            'o' , 'p' , 'q' , 'r' , 's' , 't' ,
            'u' , 'v' , 'w' , 'x' , 'y' , 'z'
    };
    public static final String[] binary = {
            "0000","1000","0100","1100",
            "0010","1010","0110","1110",
            "0001","1001","0101","1101",
            "0011","1011","0111","1111",
    };
    public static byte[] sha1(byte[] content) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA1");
            md.update(content);
            byte[] hash = md.digest();
            return hash;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }
    public static byte[] md5(byte[] content) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(content);
            byte[] hash = md.digest();
            return hash;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }
}
